package com.yunban.project.template.utils;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import net.lab1024.sa.base.common.domain.RequestUser;
import net.lab1024.sa.base.common.exception.BusinessException;
import net.lab1024.sa.base.common.util.SmartRequestUtil;
import org.springframework.stereotype.Component;

/**
 * @author: lijiajun
 * @date: 2025-03-26
 * @version: 1.0
 */
public class IdentityUtils {

    // 判断是否是客户
    public static boolean isCustomer() {
        RequestUser requestUser = SmartRequestUtil.getRequestUser();
        // 通过用户ID查询对应的角色，如果是客户，则返回true，否则返回false
        Long roleId = requestUser.getRoleId();
        if (roleId == 0L) {
            throw new BusinessException("用户身份错误，请先进行登录");
        }
        return roleId == 39L || roleId == 40L;
    }
}
